class Solution:
    def maxArea(self, h: int, w: int, horizontalCuts, verticalCuts):
        hlist=[]
        wlist=[]
        # sorted(horizontalCuts,reverse=False)
        # sorted(verticalCuts,reverse=True)
        horizontalCuts.sort(reverse=False)
        verticalCuts.sort(reverse=False)
        # print(horizontalCuts)
        hlen=len(horizontalCuts)
        vlen=len(verticalCuts)
        if hlen==1:
            hlist.append(h-horizontalCuts[-1]) 
        else:
            for i in range(hlen-1):
                hlist.append(horizontalCuts[i+1]-horizontalCuts[i])
            hlist.append(h-horizontalCuts[-1]) 
        if hlen!=1:
            hlist.append(h-horizontalCuts[-1]) 
        print(hlist)
        print(vlen)
        
        if vlen==1:
            wlist.append(w-verticalCuts[-1])
        else:
            for j in range(vlen-1):
                wlist.append(verticalCuts[j+1]-verticalCuts[j])
            wlist.append(w-verticalCuts[-1])
        print(wlist)
        res=0
        for m in hlist:
            for n in wlist:
                res=max(res,m*n)
        return res
ans=Solution().maxArea(5,4,[3,1],[1])
print(ans)